package com.xiaomaoguai.curator;

import com.xiaomaoguai.curator.common.conf.ClientConfig;
import com.xiaomaoguai.curator.common.zookeeper.client.ClientSideZkEventConsumer;
import com.xiaomaoguai.curator.common.zookeeper.client.ClientSideZkThread;
import org.aeonbits.owner.ConfigFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ FileName: ClientMain.java
 * @ Author: WeiHui-Z
 * @ Date: 2016-11-21  14:01
 * @ Version: v1.0.0
 */
public class ClientMain {

	private static final Logger LOGGER = LoggerFactory.getLogger(ClientMain.class);

	public static void main(String[] args) throws Exception {
		ClientConfig clientConfig = ConfigFactory.create(ClientConfig.class);

		// 启动时，就注册ZK相关线程
		Thread zkThread = new Thread(new ClientSideZkThread(clientConfig));
		zkThread.setDaemon(true);
		zkThread.setName("Client: ZooKeeper  Register Thread");
		zkThread.start();

		// 启动时，启动event的消费者线程
		Thread zkConsumerThread = new Thread(new ClientSideZkEventConsumer());
		zkConsumerThread.setDaemon(true);
		zkConsumerThread.setName("Consumer for Zk event...");
		zkConsumerThread.start();

		LOGGER.info("client zookeeper register thread start...");

		System.in.read();
	}
}
